package com.fish.gaiety.gateway.entity.dto;

import com.fish.gaiety.gateway.base.BaseEntity;
import com.fish.gaiety.gateway.util.BaseAuthorities;
import com.fish.gaiety.gateway.util.Gender;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;

import javax.persistence.*;

@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@Table(name = "t_user",
        indexes = {@Index(name = "USER_NAME", columnList = "name", unique = true)})
public class User extends BaseEntity {

    private String name;

    private String firstName;

    private String nickName;

    private String email;

    @Enumerated(EnumType.STRING)
    private Gender sex;

    private String password;

    public void setPassword(String password){
        this.password = NoOpPasswordEncoder.getInstance().encode(password);
    }

    @Enumerated(EnumType.STRING)
    private BaseAuthorities authorities;

    private String phone;

}
